/*
  GUIShell
  (c) 2002-2007 Jeffrey Bedard
  antiright@gmail.com

  This file is part of GUIShell.

  GUIShell is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  GUIShell is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with GUIShell; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "gtkshell.h"

static void
gsh_delete_GSHUpdatedWidget (struct GSHUpdatedWidget *item)
{
  arfree (item);
}

static void
gsh_GSHUpdatedWidget_update (struct GSHUpdatedWidget *item)
{
  /* Call function pointer specific to the updater type.  */
  item->function (item->command, item->widget);
}

struct GSHUpdatedWidget *
gsh_new_GSHUpdatedWidget (void (*function) (const gchar *, gpointer),
			  const gchar * command, GtkWidget * widget)
{
  struct GSHUpdatedWidget *updater;

  updater = armalloc (sizeof (struct GSHUpdatedWidget));
  /* Assign method function pointers.  */
  updater->update = &gsh_GSHUpdatedWidget_update;
  updater->delete = &gsh_delete_GSHUpdatedWidget;
  /* Assign widget-specific update information, specifically
   * the widget command, a pointer to the widget, and the widget's
   * updater function.  */
  updater->command = (gchar *) command;
  updater->widget = widget;
  updater->function = function;

  return updater;
}
